
from selenium import webdriver
from pageObjects.LoginPage import LoginPage
import time
from appModules.LoginAction import LoginAction
from appModules.AddContactPersonAction import AddContactPerson
from util.ParseExcel import ParseExcel
from config.VarConfig import *

excelObj = ParseExcel()
excelObj.loadWorkBook(dataFilePath)

userSheet = excelObj.getSheetByName("126账号")
isExecuteUser = excelObj.getColumn(userSheet, account_isExecute)
dataBookColumn = excelObj.getColumn(userSheet, account_dataBook)
print("测试为126邮箱添加联系人执行开始")
for idx, i in enumerate(isExecuteUser):
    if i.value == "y":
        userRow = excelObj.getRow(userSheet, idx+1)
        username = userRow[account_username-1].value
        password = userRow[account_password-1].value
        print(username,password)
        # driver = webdriver.Chrome()
        # driver.get('http://mail.126.com/')
        # LoginAction.login(driver, username, password)
        # time.sleep(3)
        dataBookName = dataBookColumn[idx+1].value
        dataSheet = excelObj.getSheetByName(dataBookName)
        isExecuteData = excelObj.getColumn(dataSheet,contacts_isExecute)
        contactNum = 0
        isExecuteNum = 0
        for id,data in enumerate(isExecuteData):
            if data.value == "y":
                isExecuteNum = isExecuteNum+1
                rowContent = excelObj.getRow(dataSheet,id+1)
                contactPersonName = rowContent[contacts_contactPersonName-1].value
                contactPersonPhone = rowContent[contacts_contactPersonPhone-1].value
                contactPersonEmail = rowContent[contacts_contactPersonEmail-1].value
                contactPersonComment = rowContent[contacts_contactPersonComment - 1].value
                assertKeyWord = rowContent[contacts_assertKeyWords - 1].value
                print(contactPersonName,contactPersonPhone,contactPersonEmail,contactPersonComment,
                      assertKeyWord)
                AddContactPerson.add(driver,)



